package io.mft.commons.db.mapper.builder;

public enum DbMapperParamType {
	StringType(String.class,2,""), 
	intType(int.class,1,Integer.valueOf(-1).intValue()), 
	floatType(float.class,3,Float.valueOf(-1).floatValue()), 
	IntegerType(Integer.class,1,Integer.valueOf(-1)),
	FloatType(Float.class,3,Float.valueOf(-1)),
	LongType(Long.class,1,Long.valueOf(-1)), 
	longType(long.class,1,Long.valueOf(-1).longValue());
/**
*  case 1: 
            cstmt.setInt(1 + i, ConvertHelper.strToInt(para_value,0));
            break;
          case 2: 
            cstmt.setString(1 + i, para_value);
            break;
          case 3: 
            cstmt.setFloat(1 + i, ConvertHelper.strToFloat(para_value));
            break;
          case 4: 
            CLOB clob = StringToClob(conn, para_value);
*/
	private Class<?> type;
	private int typeValue;
	private Object defaultValue;
	public Object getDefaultValue() {
		return defaultValue;
	}
	private DbMapperParamType(Class<?> type,int typeValue,Object defaultValue) {
		this.type = type;
		this.typeValue=typeValue;
		this.defaultValue=defaultValue;
	}
	public Class<?> getType() {
		return type;
	}
	public int typeValue() {
		return typeValue;
	}
	public static DbMapperParamType parse(Class<?> classType) {
		return parseTypeString(classType.getName());
	}
	public static DbMapperParamType parseTypeString(String typeString) {
		DbMapperParamType dbMapperParamType=null;
		DbMapperParamType[] dbMapperParamTypes=DbMapperParamType.values();
		for (DbMapperParamType t : dbMapperParamTypes) {
			if (t.getType().getName().equals(typeString)||t.getType().getSimpleName().equals(typeString)) {
				dbMapperParamType=t;
				break;
			}
		}
		return dbMapperParamType;
	}
}
